﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HallTimer.Views
{
    /// <summary>
    /// Interaction logic for SecondOutputWindow.xaml
    /// </summary>
    public partial class SecondOutputWindow : Window
    {
        // Enumeration for the output types on the second screen
        public enum Screentype
        {
            Empty,
            Notification,
            Opening,
            Song,
            Timing,
            Clock
        };

        public Page CurrentOutputPage { get; set; }

        public SecondOutputWindow()
        {
            InitializeComponent();
            secondWindowFrame.NavigationService.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(NavigationService_LoadCompleted);

            ChangeOutputWindow(Screentype.Opening);
        }

        public void NavigationService_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            CurrentOutputPage = ((Page)e.Content);
            this.Background = CurrentOutputPage.Background;
        }

        public void ChangeOutputWindow(Screentype screenType)
        {
            String pageURI = String.Empty;
            switch (screenType)
            {
                case Screentype.Clock:
                    pageURI = "Outputpages/ClockOutputPage.xaml";
                    break;
                case Screentype.Empty:
                    pageURI = "Outputpages/EmptyOutputPage.xaml";
                    break;
                case Screentype.Notification:
                    break;
                case Screentype.Opening:
                    pageURI = "Outputpages/WelcomeOutputPage.xaml";
                    break;
                case Screentype.Song:
                    pageURI = "Outputpages/SongOutputPage.xaml";
                    break;
                case Screentype.Timing:
                    pageURI = "Outputpages/TimerOutputPage.xaml";
                    break;
                // no default case
            }
            if (pageURI != String.Empty)
            {
                secondWindowFrame.Source = new Uri(pageURI, UriKind.Relative);
            }
            //this.Background = currentOutputPage.Background; // not set, so returning the page also makes no sense...
            //return currentOutputPage; // don't know if this value will have been set already... thus:
            // TODO: check this return value
        }

    }
}
